<template>
  <basic-dialog
    :visible="show"
    minWidth="600px"
    isShowBasicFooter
    :isShowInnerLoading="isShowInnerLoading"
    @close="show = false"
    @submit="submit"
    title="标记设置"
    :isFullScreen="false"
  >
    <div style="padding:20px 0 0">
      <div class="font-16 margin-b-10" style="margin-left: 24px">
        启用标记：
        <q-toggle
          size="xs"
          v-model="isToggleTrue"
          @input="onStatusToggle(props.row)"
        >
<!--        <template v-slot>-->
<!--          <q-tooltip>启用/封禁</q-tooltip>-->
<!--        </template>-->
      </q-toggle></div>
      <set-user-common :title="`标记人员`" v-model="markerList"/>
    </div>
  </basic-dialog>
</template>
<script>
// import _ from 'lodash'
import { mapActions, mapGetters } from 'vuex'
import { putMarkSetting } from 'src/boot/program-v2/sign'

export default {
  name: 'audit-dialog',
  props: {
    toolType: Number
  },
  components: {
  },
  data () {
    return {
      show: false,
      isToggleTrue: false,
      submitDisable: true,
      isShowInnerLoading: false,
      markerList: []
    }
  },
  computed: {
    ...mapGetters([
      'signFileData'
    ])
  },
  methods: {
    ...mapActions([
      'getSignFile'
    ]),
    showDialog () {
      this.show = true
      this.markerList = []
      this.getReviewer()
    },
    getReviewer () {
      this.isShowInnerLoading = true
      this.getSignFile().then((res) => {
        this.isShowInnerLoading = false
        this.isToggleTrue = res.enableFlag
        this.markerList = res.markerList.map((v) => {
          return {
            ...v,
            approver: v.id
          }
        })
      })
    },
    setData (val) {
      this.markerList = val
    },
    onStatusToggle (val) {
      console.log(val)
    },
    submit () {
      this.isShowInnerLoading = true
      const member = this.markerList.map(v => v.approver)
      const params = {
        enableFlag: this.isToggleTrue,
        markerIds: member || []
      }
      putMarkSetting(params).then(res => {
        this.isShowInnerLoading = false
        res.success && this.$message.success('设置成功')
        this.getSignFile()
        this.$emit('refreshFun')
        this.show = false
      }).catch(err => {
        this.isShowInnerLoading = false
        console.log(err)
      })
    }
  }
}
</script>

<style scoped lang="scss">
</style>
